Help with conditional

Questions about MultiCharts and user contributed studies.
Stowed4Sea
Posts: 4
Joined: 26 Feb 2022

Help with conditional

Postby Stowed4Sea » 08 Mar 2022

So, below is my code. Not shown is another conditional to set CumulativeDeltaCheckShort=True if it meets my requirements for the trade, but that bit isn't important.

What is important, is that with chart setup for 5 minute bars, and IntrabarOrderGeneration=True, when I run this code live with autotrading in real time, I see "Delta Check Fail Short" flicker on and off lots of times during that bar. For context price was right at my conditional for entry, and CumulativeDeltaCheckShort was bouncing from true to false based on cumulative delta bouncing back and forth in and out of my entry requirements.

My question is: Shouldn't this only happen once? The first time it failed it sets CumulativeDeltaCheckShortFailure=True and should never run again that day, or what don't I understand?

Code: Select all

IF [all my conditionals for trade] AND (CumulativeDeltaCheckShortFailure=False) AND FirstTrade then begin IF CumulativeDeltaCheckShort then begin FirstTrade=False; SellShort("FadeIBH") MyQty contracts next bar market; end else begin CumulativeDeltaCheckShortFailure=True; PlotText=Text_new(Date,Time,(IBH-((IBH-IBL)/2)),"Delta Check Fail Short"); Text_SetSize(PlotText, 7); //Give chance to reset itself maybe later, but fail for now so we don't mistakenly enter at odd place end; end;
The only place CumulativeDeltaCheckShortFailure gets set back false is below:

Code: Select all

IF Date>Date[1] then begin CumulativeDeltaCheckShortFailure=False; //Other Stuff Also end;
So, I guess I don't understand how multicharts executes scripts. I've read this page and it also discusses intrabar order generation, but I mean even if it's re-evaluated, shouldn't my CumulativeDeltaCheckShortFailure still be false, so on re-evaluation each tick of that bar, like it says, it should be false right? If not I need some help understanding why.

Thanks all.
Daniel

Return to “MultiCharts”