Place orders when a curve change colour

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #19774 quote
    Dave
    Participant
    Senior

    Hi Robert123/nicolas,

    Is it then possible to place an order if the MA has changed colour?

    Dave

    #19775 quote
    Nicolas
    Keymaster
    Master

    @Dave
    Yes of course, because there are conditions that make the curve change its colour, so you’ll use these conditions values instead of the colour changing itself.
    In my example in this post, I use 2 conditions named “bullish” and “bearish”, you have to define them first, what is your definition of a bullish trend that make change the color of the curve?

    #19780 quote
    Dave
    Participant
    Senior

    My thought were around it placing a small order each time the MA changes colour/direction in agreement with that of a slower MA.

    #19786 quote
    Nicolas
    Keymaster
    Master

    Ok, but what cause the moving average to change its colour? 🙂

    #19865 quote
    Dave
    Participant
    Senior

    Nicolas, apologies for the delay, Moving average changes colour because average price of ‘x’ periods is increasing (bullish) as each candle candle forms.

    #19898 quote
    Nicolas
    Keymaster
    Master

    FYI, I moved your request to a fresh new topic in the appropriate part of the forum.

    So, about your trading strategy, it can be coded like this (bullish side only):

    X = 10 //moving average period 
    takeprofit = 30 //takeprofit in points
    stoploss = 60 //stoploss in points
    
    ma = average[X](close)
    
    // the moving average is changing direction from bearish to bullish
    bullish = ma>ma[1] and ma[1]<ma[2] 
    
    if not longonmarket and bullish then 
     buy 1 share at market 
    endif 
    
    set target pprofit takeprofit
    set stop ploss stoploss

    With this code, the trade is not closed with a bearish signal (from green to red), but only with takeprofit or stoploss. But this is a good start to improve the strategy.

    #19931 quote
    Dave
    Participant
    Senior

    Thanks Nicolas, I will do my best to apply it to a couple of ideas I have when I’m back at my desk.

    Dave

    #19969 quote
    Dave
    Participant
    Senior

    I dropped it on todays dax 15 chart and it took four nice trades (sl/tp reduced to 20 to see more triggers) ,could you clarify simply what line 8 means (I’m still only at ‘assisted creation’ level in logic terms!!  🙂   ), is this the reason the order is placed on the third candle after the ma has changed colour or does the indicator paint this back as it calculates?.

    regards

    Dave

    curve050117.jpg curve050117.jpg
    #19976 quote
    Nicolas
    Keymaster
    Master

    The line 8 is the signal condition that trigger a long trade. Trades are opened at the open of the next candle that found the pattern.

    #19980 quote
    Dave
    Participant
    Senior

    It’s the braketed ma[1]& [2] part I’m struggling with?

    #19981 quote
    Nicolas
    Keymaster
    Master

    It refers to the moving average ‘MA’ variable defined at line 5 and offset back with 1 or 2 candlesticks before the current one.

    #19982 quote
    Dave
    Participant
    Senior

    Thanks Nicolas, that’s what I guessed it was. Your patience is much appreciated.

    #21522 quote
    Dave
    Participant
    Senior
    Ok Nicolas, So if I understand correctly the line says bullish = ma greater than 1 period back and ma 1 period back is less than 2 periods back because at that point it was decreasing or bearish?. You know where I’m going with this my friend, So if the ma was bullish turning bearish the the code should read :-

    bearish = ma<ma[1] and ma[1]>ma[2]

    #21525 quote
    Nicolas
    Keymaster
    Master
    Yes, this is the correct syntax for a new bearish reversal. Well done 🙂
    #23373 quote
    Dave
    Participant
    Senior
    OK, so here is a simple complete program with buy and sell conditions.It simply looks for a fast ma above a slow ma and places an order when the fast ma changes direction in agreement with slow ma.any ideas on improvements/filters/ma combinations etc most welcome. dave
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    DEFPARAM FLATBEFORE = 080000
    DEFPARAM FLATAFTER = 180000
    
    
    takeprofit = 5 //takeprofit in points
    stoploss = 10 //stoploss in points
    fastma = ExponentialAverage[11](close)
    slowma = ExponentialAverage[89](close)
    
    //fastma bullish and bearish conditions
    
    fastbullish = fastma>fastma[1] and fastma[1]<fastma[2] and fastma>slowma
    fastbearish = fastma<fastma[1] and fastma[1]>fastma[2] and fastma<slowma
    
    //conditions for long = fast ma ABOVE slow ma and turning in agreement with slow ma trend
    if not longonmarket and fastbullish  then
    buy 1 share at market
    endif
    
    //conditions for short = fast ma BELOW slow ma and in agreement with slow ma trend
    if not shortonmarket and fastbearish then
    sellshort 1 share at market
    endif
    
    set target pprofit takeprofit
    set stop ploss stoploss
    //set stop ptrailing 12
    
    Nicolas thanked this post
    EMA-Change-colour.itf
Viewing 15 posts - 1 through 15 (of 15 total)
  • You must be logged in to reply to this topic.

Place orders when a curve change colour


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Dave @dave Participant
Summary

This topic contains 14 replies,
has 2 voices, and was last updated by Dave
9 years ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 01/04/2017
Status: Active
Attachments: No files
Logo Logo
Loading...