Conversion of a trend following strategy from the MultiCharts trading software

Forums ProRealTime English forum ProBuilder support Conversion of a trend following strategy from the MultiCharts trading software

Viewing 2 posts - 1 through 2 (of 2 total)
  • #234718

    Hello, I am wondering if you can help on this translation from PowerLanguage (Multicharts) to Prorealcode. Please note; in the original code  the variable  OpenS(1), (HighS(1), LowS(1) and CloseS(1) are the OHLC of yesteday’s exchange session (18.00 open – 17.00 close, ET time), equal to my local time 23.00 open – 22.00 close GMT time. I am not clear how to translate this in Prorealcode, keeping the default settings, if possible, on the chart.

    Thanks for your support.

    =============================

    Inputs: MyContracts(1), MyStop(1470);
    Variable: SessionStartTimeA(1800), sessionEndTimeA(1700);
    variable: FastSMA(0), SlowSMA(0), DailySetupLong(false), DailySetupShort(false), GradientCheck(false);
    variable: Spread(0.02), MyStartTime(1900), MyEndTime(1600), MyStartPause(2000), MyEndPause(2000), MaxEntriesPerDay(2), MaxDaysInTrade(4);
    variable: myTimeframe(60), myFastLength(12), mySlowLength(24), myGradientLength(2), myDailyFactor(0.5), myGradientFactor(1.6);
    //VARIABLES CALCULATION
    FastSMA = Average(close, myFastLength);
    SlowSMA = Average(close, mySlowLength);
    if currentbar > 1440/myTimeframe then begin //To not divide by 0 on the first bars
    DailySetupLong = absvalue(CloseS(1)-OpenS(1))/(HighS(1)-LowS(1)) <= myDailyFactor and CloseS(1) > OpenS(1);
    DailySetupShort = absvalue(CloseS(1)-OpenS(1))/(HighS(1)-LowS(1)) <= myDailyFactor and CloseS(1) < OpenS(1);
    GradientCheck = absvalue(FastSMA – FastSMA[myGradientLength]) >= myGradientFactor*absvalue(SlowSMA – SlowSMA[myGradientLength]);
    end;
    //ENTRIES
    if tw(MyStartTime,MyEndTime) and (Time<MyStartPause or Time>MyEndPause) and entriestoday(date)<MaxEntriesPerDay then begin
    if marketposition = 0 and DailySetupLong and GradientCheck and FastSMA crosses above SlowSMA then begin
      value1 = close+spread;
    buy(“LE”) mycontracts contracts next bar at value1 limit;
    end;
    if marketposition = 0 and DailySetupShort and GradientCheck and FastSMA crosses below SlowSMA then begin
    value2 = close-spread;
    sellshort(“SE”) mycontracts contracts next bar at value2 limit;
    end;
    end;
    //EXITS
    if (date – entrydate) >= MaxDaysinTrade then setexitonclose;
    if dayofweek(date) = 5 then setexitonclose;
    if FastSMA crosses below SlowSMA then sell(“LX”) next bar at market;
    if FastSMA crosses above SlowSMA then buytocover(“SX”) next bar at market;
    setstopcontract;
    if mystop>0 then setstoploss(MyStop);
    #234731

    Hi! here you have the code:

    1 user thanked author for this post.
Viewing 2 posts - 1 through 2 (of 2 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login