I'm wondering if someone can give me an idea of how to capture the Close[0] when a condition is met and then record that data for future use? Thanks
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Getting Close[0] when conditions met
Collapse
X
-
Getting Close[0] when conditions met
Hello,
I'm wondering if someone can give me an idea of how to capture the Close[0] when a condition is met and then record that data for future use? ThanksTags: None
-
-
Originally posted by CaptainAmericaXX View PostHello,
I'm wondering if someone can give me an idea of how to capture the Close[0] when a condition is met and then record that data for future use? ThanksCode:private double CaptainAmericaMegaBucksPrice = -1;
Code:if (ConditionMet && CaptainAmericaMegaBucksPrice < 0) { CaptainAmericaMegaBucksPrice = Close[0]; } MakeMegaBucks(CaptainAmericaMegaBucksPrice, ...); if (PositionHasBeenClosed || WeNeedToReset) { CaptainAmericaMegaBucksPrice = -1; //or whatever the initial unset value is supposed to be. }
Comment
-
koganam, you're awesome! I swear if I ever start making money trading I'm going to send you a check!
I tried to follow your advice. I'm ok at plugging what others give me, but not very good at figuring it out myself. Here is what I have so far:
Code:private double closeprice = -1;
So what I want to do is capture the Close[0] at the CrossAbove. I then want to look back x amount of bars to see if there was a cross at that exact price. Is what you gave me along those lines? I especially like the "MakeMegaBuck" (I know you just made that up), but I have to admit I don't have the foggiest idea what that line is going to accomplish. Do you have some more advice?Code:if (CrossAbove(RSMarketDirection(12).UpTrend, RSMarketDirection(12).SMALine, 1) && vcloseprice < 0) { closeprice = Close[0]; } MakeMegaBucks(closeprice); if (PositionHasBeenClosed || WeNeedToReset) { closeprice = -1; }
Comment
-
Pretty much. Once you have captured the price of interest, all you need to do is call another method to see if your condition is filled. In this case, I would use the MIN() and MAX() classes to find the MIN and MAX values starting from the bar on which I captured closeprice, and going back your x number of bars. If MIN is below the cross line, and MAX is above it, then there was at least one cross.Originally posted by CaptainAmericaXX View Postkoganam, you're awesome! I swear if I ever start making money trading I'm going to send you a check!
I tried to follow your advice. I'm ok at plugging what others give me, but not very good at figuring it out myself. Here is what I have so far:
Code:private double closeprice = -1;
So what I want to do is capture the Close[0] at the CrossAbove. I then want to look back x amount of bars to see if there was a cross at that exact price. Is what you gave me along those lines? I especially like the "MakeMegaBuck" (I know you just made that up), but I have to admit I don't have the foggiest idea what that line is going to accomplish. Do you have some more advice?Code:if (CrossAbove(RSMarketDirection(12).UpTrend, RSMarketDirection(12).SMALine, 1) && vcloseprice < 0) { closeprice = Close[0];[COLOR=blue] //good enough[/COLOR] } MakeMegaBucks(closeprice); [COLOR=blue]//this just represents all the stuff that you want to do with the information that you have captured above. It was just a placeholder.[/COLOR] if (PositionHasBeenClosed || WeNeedToReset) [COLOR=blue]//this is just a description of when you want to reset your variable, so that you do not have unintended side effects.[/COLOR] { closeprice = -1; }
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
630 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
364 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
105 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
565 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
568 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment