Can anyone help with this Tradestation (TS) translation to MQ4??
Appreciate Any help or referral
Ray
Inserted Code
[font=Times New Roman][b]Tradestation Code:[/b][/font] [font=Times New Roman]{This a Tradestation platform Keltner Channel EA}[/font] [font=Times New Roman][color=#99cc00]{ The IntrabarOrderGeneration attribute is set to false in this strategy because strategy calculations [/color][/font] [font=Times New Roman][color=#99cc00]depend on end-of-bar prices. Specifically, an "Average True Range" is calculated. [/color][/font] [font=Times New Roman][color=#99cc00]Calculation of Average True Range depends on end-of-bar high, low, and closing prices. }[/color][/font] [font=Times New Roman][IntrabarOrderGeneration = false] [b][color=#993366]{not sure if MT4 has same??}[/color][/b][/font] [font=Times New Roman]inputs: Price( Close ), Length( 20 ), NumATRs( 1.5 ) ;[/font] [font=Times New Roman]variables: Avg( 0 ), Shift( 0 ), UpperBand( 0 ), Setup( false ), CrossingHigh( 0 ) ,[/font] [font=Times New Roman]LowerBand( 0 ), CrossingLow( 0 ) ;[/font] [font=Times New Roman]Avg = [color=red]AverageFC[/color]( Price, LengthKC ) ; [b][color=#993366]{AverageFC-How to in MT4 ??}[/color][/b][/font] [font=Times New Roman]Shift = NumATRs * [color=red]AvgTrueRange[/color]( LengthKC ) ;[/font] [font=Times New Roman]UpperBand = Avg + Shift ;[/font] [font=Times New Roman]LowerBand = Avg - Shift ;[/font] [font=Times New Roman][color=#99cc00]{--Long--}[/color][/font] [font=Times New Roman]if CurrentBar > 1 and Price crosses over UpperBand then [b][color=#993366]{CurrentBar >1 ??}[/color][/b][/font] [font=Times New Roman][color=#99cc00]{ CB > 1 check used to avoid spurious cross confirmation at CB = 1 }[/color][/font] [font=Times New Roman] begin[/font] [font=Times New Roman] SetUp = true ;[/font] [font=Times New Roman] CrossingHigh = High ;[/font] [font=Times New Roman] end [/font] [font=Times New Roman]else if Setup and ( Price < Avg or High >= CrossingHigh + 1 point ) then [b][color=#993366]{CrossingHigh + 1 Point ??}[/color][/b][/font] [font=Times New Roman] Setup = false ;[/font] [font=Times New Roman] [color=#99cc00]{ the High >= condition being true indicates that a buy must already have been triggered[/color][/font] [font=Times New Roman][color=#99cc00]at this bar so this setup has been used up and needs to be negated; an example of a [/color][/font] [font=Times New Roman][color=#99cc00]persisitent setup with an indefinite stop/limit trigger - setup has to be negated after[/color][/font] [font=Times New Roman][color=#99cc00]entry confirmed; also see Pivot Reversal LE/SE and PercentR LE/SE }[/color][/font] [font=Times New Roman]if Setup and marketposition = 0 or marketposition = -1 then [/font] [font=Times New Roman] Buy ( "KltChLEv2a1" )iQuantity shares next bar at CrossingHigh + 1 point stop ;[/font] [font=Times New Roman][b][color=#993366]{CrossingHigh + 1 Point ??}[/color][/b][/font] [font=Times New Roman][b]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++[/b][/font] [font=Times New Roman][b]MT4 Code: ????[/b][/font] [font=Times New Roman]bool BuySignal() [/font] [font=Times New Roman]{[/font] [font=Times New Roman] double Setup, CrossingHigh;[/font] [font=Times New Roman] double upper =iCustom(NULL,0,"RK-KeltnerChannel-atr",KCperiod,KCatr,0,ShiftKC+0);[/font] [font=Times New Roman] double middle=iCustom(NULL,0,"RK-KeltnerChannel-atr",KCperiod,KCatr,1,ShiftKC+0);[/font] [font=Times New Roman] double lower =iCustom(NULL,0,"RK-KeltnerChannel-atr",KCperiod,KCatr,2,ShiftKC+0); [/font] [font=Times New Roman]if (Close [0] > upper && Close [1] < upper ) //Price Xs over upper (What is CurrentBar >1)[/font] [font=Times New Roman] {[/font] [font=Times New Roman]Setup = True;[/font] [font=Times New Roman]CrossingHigh = High; [/font] [font=Times New Roman] }[/font] [font=Times New Roman] else[/font] [font=Times New Roman] {[/font] [font=Times New Roman] if (Setup && (Close < middle || High >= (CrossingHigh+1 Point)) //(Crossing High +1 point) ???[/font] [font=Times New Roman] {[/font] [font=Times New Roman] Setup = False;[/font] [font=Times New Roman] } [/font] [font=Times New Roman] if (Setup && TimeCondition())[/font] [font=Times New Roman] { [/font] [font=Times New Roman] return(true); // sends out a buy[/font] [font=Times New Roman] return(false); //no trade signal[/font] [font=Times New Roman] }[/font] [font=Times New Roman] }[/font] [font=Times New Roman]} [/font]
Appreciate Any help or referral
Ray