General idea: Check for signal OnTick Signal is observed each tick but corresponds to movements on larger timeframes Signal equal to movement of 1 pip each time over a predefined time period CheckSignal Declarations Inputs: - # of intervals to check move over (for signal) - interval size to check move over (for signal) - trading day length - define hours between which this signal is observed - intrabar setting - type of signal observation - 0 for End of Bar observation, 1 for intra-bar observation AdjustSlTp Declarations - initial stop loss interval (hardcoded number) - initial take profit interval (hardcoded number) - maximum amount of time to keep position on - maximum position size (integer 1-10) - tp adjustment step - amount by which take profit gets adjusted each time price moves - sl adjustment step - amount by which stop loss gets adjusted each time price moves - stops adjustment step - amount by which px needs to move for SL or TP levels to get adjusted - stop adjustment max steps - how many times a trailing stop can get adjusted Main Function: OnTick - check if current takeprofit or stoploss achieved on each position; liquidate if reached - check if time limit for each position reached; liquidate if reached - run AdjustSlTp function - run CheckSignal function CheckSignal + signal move size = 1 pip - signal move size = 1 pip - if intrabar setting = 0 - if now = BarClose, calculate result = px now - px at [t -# intervlas * interval size] - if result > + signal move size, long Signal - if result < - signal move size, short Signal - run OnSignal function - if result < signal move size, next tick - if now <> BarClose, next tick - if intrabar setting = 1 - calculate result = px now - px at BarOpen - if result > + signal move size, long Signal - if result < - signal move size, short Signal - run OnSignal function - if result < signal move size, next tick AdjustSlTp - loop through all open positions through max_limit - for each position index - if current price better than original entry by stops adjustment step - check if stop adjustment max steps reached, if not - increase sl level by sl adjustment step - increase tp level by tp adjustment step - if time since trade reaches max, liquidate OnSignal - check if position limit reached - if reached, next tick - if not, add 1 lot to position - set sl, tp levels - next tick