Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {*
- ========================================================================
- Strategy: @@Team47_StrMultipleTimeFrames
- ========================================================================
- *}
- {*
- ========================================================================
- === Input Parameters
- ========================================================================
- *}
- Input:
- INT n(3), // n - barinterval multiplier
- INT k_Length(8), // k - sequence length
- INT m_Bars(8), // m - max number of bars in position
- FLOAT ProfitPct(20.0); // Profit %
- {*
- ======================================================================================================
- === Start of Implementation
- ======================================================================================================
- *}
- // Constants ----------------------------------------------------------
- //-----------------------------------------------------------------------
- Constants:
- INT DataArraySize(50);
- //----------------------------------------------------------------------
- // Data Processing
- //----------------------------------------------------------------------
- Array:
- Data2BarsHigh[DataArraySize](0),
- Data2BarsLow[DataArraySize](0)
- Data1BarsHigh[DataArraySize*n](0),
- Data1BarsLow[DataArraySize*n](0),
- Data2BarsClose[DataArraySize](0);
- Data2BarsHigh[BarNumber[0]]=high;
- Data2BarsLow[BarNumber[0]]=low;
- if BarNumber[0]%n=0 then begin
- Data2BarsHigh[BarNumber[0]/n]=high;
- Data2BarsLow[BarNumber[0]/n]=low;
- Data2BarsClose[BarNumber[0]/n] = close;
- end;
- // Data2 Construction --------------------------------------------------
- //----------------------------------------------------------------------
- //----------------------------------------------------------------------
- //----------------------------------------------------------------------
- // END - Data Processing -----------------------------------------------
- //----------------------------------------------------------------------
- //----------------------------------------------------------------------
- // Events Identification
- //----------------------------------------------------------------------
- // Check k-High Sequence -----------------------------------------------
- //----------------------------------------------------------------------
- Vars:
- BOOL k_SequenceFound(FALSE);
- INT num_of_last_bar_selled(DataArraySize);
- k_SequenceFound=TRUE;
- for j=0 to k_Length-1 begin
- if Data2BarsHigh[((BarNumber[1])/n)-(j+1)]>Data2BarsHigh[(BarNumber[1])/n-j] then begin
- k_SequenceFound = FALSE;
- end;
- end;
- //k_SequenceFound = TRUE/FALSE;
- //----------------------------------------------------------------------
- // End::Events Identification
- //----------------------------------------------------------------------
- //----------------------------------------------------------------------
- // Strategy
- //----------------------------------------------------------------------
- // Short Entry ---------------------------------------------------------
- //----------------------------------------------------------------------
- if k_SequenceFound=TRUE AND Data2BarsLow[((BarNumber[1])/n)] = 0.05+Data1BarsLow[(BarNumber[0])] and (BarNumber[1])%n=0) then begin
- sellshort this bar at Market;
- num_of_last_bar_selled = BarNumber[0];
- end;
- //----------------------------------------------------------------------
- // Short Exit ----------------------------------------------------------
- //----------------------------------------------------------------------
- if ProfitPct < (Data2BarsClose[(BarNumber[1])/n] -Data2BarsClose[((BarNumber[1])/n )+1])/Data2BarsClose[(BarNumber[1])/n]) OR num_of_last_bar_selled+m_Bars = BarNumber[0] then begin
- BuyToCover this bar at Market;
- end;
- //----------------------------------------------------------------------
- // StopLoss Exit
- //----------------------------------------------------------------------
- SetStopShare;
- if Data2BarsHigh[(num_of_last_bar_selled-1)/n]-0.02>high) then begin
- BuyToCover this bar at Market;
- end;
- //----------------------------------------------------------------------
- //----------------------------------------------------------------------
- // End:: Strategy
- //----------------------------------------------------------------------
- {*
- ======================================================================================================
- === End of Implementation
- ======================================================================================================
- *}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement