HELP for enter a long position if its under the average

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #40082 quote
    RaggadownRaggadown
    Participant
    New

    Hey fellow coding humans,

    Im new to this and have stumbled across a problem i need help with.

    Im trying to simply tell my system that i dont want it to enter a long position if its under the average (110)

    heres and extract from my code:

    mo= average(110)
    
    IF not longonmarket and upbox + boxsize crosses over mo or upbox + boxsize > mo THEN
    buy 10 share at market
    Elsif barindex crosses under mo or barindex < mo or tradeindex < mo then
    buy 0 share at market

     

    upbox and downbox  are defined params.   I have tried everything to try to stop it from placing LONG positions under the average (110) e.g. ELSIF upbox + downbox<mo THEN etc.

    it is still buying long positions.

    what am i doing wrong?

    many thanks lovely people.

    #40202 quote
    NicolasNicolas
    Keymaster
    Legend

    Please provide the full code of your strategy as I don’t know what values are stored into your upbox+boxsize variables.

    #40256 quote
    GraHalGraHal
    Participant
    Master

    Instead of not entering if under MA(110) why not have a condition added to your other Long entry conditions …

    If Condition X AND Condition Y AND Close >= Average(110) Then
    Buy 1 Contract at Market
    EnfIF

    Or have I missed the point?? 🙂

    #40263 quote
    DespairDespair
    Blocked
    Master

    I second Grahal in this one. 😉

    GraHal thanked this post
    #40568 quote
    RaggadownRaggadown
    Participant
    New

    Great many thanks guys. That really helped. Ive sorted it now.

    Just another question about the mechanics of automated trading if i may?

    I have written a multiple moving average crossover strategy for the hourly USD/JPY which returns over 100% a year. If i then apply this to the EUR/GBP it losses money.

    Is this because i have been writing / altering the code to suit the backtesting of  the USD/JPY? And do i need to get the code working well on all pairs before implementing? Or is this normal that these types of strategy suit some pairs more than others?

     

    many thanks

    #40598 quote
    GraHalGraHal
    Participant
    Master

    You asked … is this normal that these types of strategy suit some pairs more than others? … Yes, but usually it’s due to the value of the variables have been optimised for a particular forex pair etc.

    You said … which returns over 100% a year … you sure you have the ‘tick mode box’ enabled as this sounds too good to be true?

    Make sure you run in Demo for weeks / months before you go Live and maybe lose your hard earned money??

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

HELP for enter a long position if its under the average


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Raggadown @raggadown Participant
Summary

This topic contains 5 replies,
has 4 voices, and was last updated by GraHalGraHal
9 years, 2 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 07/08/2017
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...