Expert Advisor Implement.

 

Hello guys, sorry if this is the wrong topic but im new here.

I'm trying to develop an Expert Advisor that is based on TCCI indicator.

The EA that im building should open a trade in buy when the line is green, in sell when is red.

The only problem that i have is that i dont know hot setup stop loss or take profit.

I want that the trade will close only when the line change color not with amount of pips. Could someone help me how to do it and how to write and add into the programm ?

Thanks to all !

 
what pratform you work? MT4 or MT5. Please insert your code if you need to help.
 

Im working in mt4 

As i said i put tp and sl for example..

(updated the file cause i discovered one mistake)
 
Topics concerning MT4 and MQL4 have their own section.
In future please post in the correct section.
I have moved your topic to the MQL4 and Metatrader 4 section.
 
Nguyen Tien Duong:
what pratform you work? MT4 or MT5. Please insert your code if you need to help.
I will be very happy if you can give me a hand :/
 
emygamey: I will be very happy if you can give me a hand :/

emygamey:

The only problem that i have is that i dont know hot setup stop loss or take profit.

I want that the trade will close only when the line change color not with amount of pips. Could someone help me how to do it and how to write and add into the programm ?

  1. Help you with what? You haven't stated a problem, you stated a want. Show us your attempt (using the CODE button) and state the nature of your problem.
              No free help 2017.04.21

    Or pay someone. Top of every page is the link Freelance.
              Hiring to write script - General - MQL5 programming forum 2018.05.12

    We're not going to code it for you (although it could happen if you are lucky or the problem is interesting).
              No free help 2017.04.21

  2. If you are closing by a condition, there is no Take Profit. You already have code that tries to do exactly that. What's the problem?

  3. Risk depends on your initial stop loss, lot size, and the value of the symbol. It does not depend on margin and leverage. No SL means you have infinite risk. Never risk more than a small percentage of your trading funds, certainly less than 2% per trade, 6% total.

    1. You place the stop where it needs to be — where the reason for the trade is no longer valid. E.g. trading a support bounce the stop goes below the support.

    2. AccountBalance * percent/100 = RISK = OrderLots * (|OrderOpenPrice - OrderStopLoss| * DeltaPerLot + CommissionPerLot) (Note OOP-OSL includes the spread, and DeltaPerLot is usually around $10/pip but it takes account of the exchange rates of the pair vs. your account currency.)

    3. Do NOT use TickValue by itself - DeltaPerLot and verify that MODE_TICKVALUE is returning a value in your deposit currency, as promised by the documentation, or whether it is returning a value in the instrument's base currency.
                MODE_TICKVALUE is not reliable on non-fx instruments with many brokers - MQL4 programming forum 2017.10.10
                Is there an universal solution for Tick value? - Currency Pairs - General - MQL5 programming forum 2018.02.11
                Lot value calculation off by a factor of 100 - MQL5 programming forum 2019.07.19

    4. You must normalize lots properly and check against min and max.

    5. You must also check FreeMargin to avoid stop out

    Most pairs are worth about $10 per PIP. A $5 risk with a (very small) 5 PIP SL is $5/$10/5 or 0.1 Lots maximum.

 
William Roeder:
  1. Help you with what? You haven't stated a problem, you stated a want. Show us your attempt (using the CODE button) and state the nature of your problem.
              No free help 2017.04.21

    Or pay someone. Top of every page is the link Freelance.
              Hiring to write script - General - MQL5 programming forum 2018.05.12

    We're not going to code it for you (although it could happen if you are lucky or the problem is interesting).
              No free help 2017.04.21

  2. If you are closing by a condition, there is no Take Profit. You already have code that tries to do exactly that. What's the problem?

  3. Risk depends on your initial stop loss, lot size, and the value of the symbol. It does not depend on margin and leverage. No SL means you have infinite risk. Never risk more than a small percentage of your trading funds, certainly less than 2% per trade, 6% total.

    1. You place the stop where it needs to be — where the reason for the trade is no longer valid. E.g. trading a support bounce the stop goes below the support.

    2. AccountBalance * percent/100 = RISK = OrderLots * (|OrderOpenPrice - OrderStopLoss| * DeltaPerLot + CommissionPerLot) (Note OOP-OSL includes the spread, and DeltaPerLot is usually around $10/pip but it takes account of the exchange rates of the pair vs. your account currency.)

    3. Do NOT use TickValue by itself - DeltaPerLot and verify that MODE_TICKVALUE is returning a value in your deposit currency, as promised by the documentation, or whether it is returning a value in the instrument's base currency.
                MODE_TICKVALUE is not reliable on non-fx instruments with many brokers - MQL4 programming forum 2017.10.10
                Is there an universal solution for Tick value? - Currency Pairs - General - MQL5 programming forum 2018.02.11
                Lot value calculation off by a factor of 100 - MQL5 programming forum 2019.07.19

    4. You must normalize lots properly and check against min and max.

    5. You must also check FreeMargin to avoid stop out

    Most pairs are worth about $10 per PIP. A $5 risk with a (very small) 5 PIP SL is $5/$10/5 or 0.1 Lots maximum.

Ok, you’re right. But i have a problem not a “want”. I coded this EA but he dont open only one trade but it open multiple trades, can someone help me or explain me how to fix it, or i need to pay also for this ?
 
emygamey But i have a problem not a “want”. I coded this EA but he dont open only one trade but it open multiple trades,
  1. You've now changed to a completely different subject.

  2. bool buyCondition    =  (currentDn > currentUp );
    bool sellCondition   =  (currentUp > currentDn);

    You are looking at a signal. Act on a change of signal.
              MQL4 (in Strategy Tester) - double testing of entry conditions - MQL5 programming forum #1 2017.12.12

  3. Or check for an open order before opening another.

Reason: