Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Help me with a order
Collapse
X
-
firecan, we can for sure understand the frustrations involved in custom coding and debugging, however unfortunately we would not offer such services - if you want this code rather professionally custom developed for you the best option would be checking with a certified NinjaScript consultant -
-
Sorry, I am tired of trying to run the script, I take two months and nothing. If possible, please make it work will be grateful.
Leave a comment:
-
firecan,
Make sure you are managing your bool variables effectively. They should be true initially and also reset back to true once you're flat.
To help debug this: You can add print statements to any block of code to check if it's being processed properly.
Simplify to a two stage movement first and verify this is working properly, before adding more movements.
Leave a comment:
-
{
if (Close[0] >= Position.AvgPrice +3 * TickSize && PriMove)
{ SetStopLoss(CalculationMode.Price,Position.AvgPric e -5 * TickSize); PriMove = false; }
if (Close[0] >= Position.AvgPrice +8 * TickSize && SegMove)
{ SetStopLoss(CalculationMode.Price,Position.AvgPric e +1 * TickSize); SegMove = false; }
if (Close[0] >= Position.AvgPrice +14 * TickSize && TerMove)
{ SetStopLoss(CalculationMode.Price,Position.AvgPric e +7 * TickSize); TerMove = false; }
if (Close[0] >= Position.AvgPrice +20 * TickSize)
{ SetStopLoss(CalculationMode.Price,Position.AvgPric e +15 * TickSize);}
}
// Condicion de Entrada en Largo.
if (ToTime(Time[0]) == ToTime(horas,minutos,00))
{ EnterLongStop(0,true,contratos,Close[0] +7 * TickSize, "Largo 1"); }
Leave a comment:
-
protectedoverridevoid Initialize()
{
SetStopLoss(CalculationMode.Ticks, stoplossticks);
SetProfitTarget(CalculationMode.Ticks, profittargetticks);
TraceOrders = true ;
CalculateOnBarClose = true;
}
protectedoverridevoid OnBarUpdate()
{
// Resetea stop loss y profit al cerrar la posicion.
if (Position.MarketPosition == MarketPosition.Flat)
{ SetStopLoss(CalculationMode.Ticks, stoplossticks); }
// Abierta una posicion Larga, modifica el Stop Loss a Breakeven.
if (Position.MarketPosition == MarketPosition.Long)
Leave a comment:
-
Hello.
I re-wrote the scrip without variables to make it look more clear about what I do.
Could you make it run and tell me where is the error it does not work.
I try to place a pending order on the market at a particular time. And run the stop loss 3 times when touch each price set, without wait close a bar.
I do not why the stop loss only run when the price is +20 , and forget +3 , +8 an +14 ticks.
Regards
Leave a comment:
-
firecan,
You want to reset the stop loss to an initial value when flat. You also want to reset your bool flag.
if (Position.MarketPosition == MarketPosition.Flat)
{
SetStopLoss(CalculationMode.Ticks, 20);
PriMove = true;
}
Leave a comment:
-
Hello again, sorry.
I'm confused . Please, could you write me the missing piece of code and tell me where I put it, thanks
Regards.
Leave a comment:
-
Hello,
These are variable declarations when the script is loaded.
You need to reset this Inside of as well when it is needed to be reset.
OnBarUpdate()
{
}
Let me know if I can be of further assistance.
Leave a comment:
-
I have :
#region Variables
private int contratos = 1;
private int profittargetticks = 50;
private int stoplossticks = 10;
private int distmercado = 7;
private int distbreak1 = 0;
private int enviabreak1 = 0;
private int distbreak2 = 0;
private int enviabreak2 = 0;
private int horas = 0;
private int minutos = 0;
private bool PriMove = true;
#endregion
Leave a comment:
-
firecan,
Your code uses PriMove, but you never reset its value anywhere. You will most likely need logic to reset it or else it will only act once and then never again.
Leave a comment:
-
Hello again.
This is the code, can you tell me if is it ok.
protectedoverridevoid Initialize()
{
SetStopLoss(CalculationMode.Ticks, stoplossticks);
SetProfitTarget(CalculationMode.Ticks, profittargetticks);
TraceOrders = true ;
CalculateOnBarClose = true;
}
protectedoverridevoid OnBarUpdate()
{
// Resetea stop loss y profit al cerrar la posicion.
if (Position.MarketPosition == MarketPosition.Flat)
{ SetStopLoss(CalculationMode.Ticks, stoplossticks); }
// Abierta una posicion Larga, modifica el Stop Loss a Breakeven.
elseif (Position.MarketPosition == MarketPosition.Long)
{
/* Cuando el precio es mayor que la entrada en + ? ticks
envia el Stop Loss a Breakeven +/- ? */
if (Close[0] >= Position.AvgPrice + distbreak1 * TickSize && PriMove)
{ SetStopLoss(CalculationMode.Price,Position.AvgPric e - enviabreak1 * TickSize); PriMove = false; }
if (Close[0] >= Position.AvgPrice + distbreak2 * TickSize)
{ SetStopLoss(CalculationMode.Price,Position.AvgPric e + enviabreak2 * TickSize); }
}
// Condicion de Entrada en Largo.
if (ToTime(Time[0]) == ToTime(horas,minutos,00))
{ EnterLongStop(0, true, contratos, Close[0] + distmercado * TickSize, "Largo 1"); }
Leave a comment:
-
Originally posted by firecan View PostHello.
Dont run OK, something I'm doing wrong.
Maybe dont understand "Reset these variables when you're flat."
How can I do it.
Regards.
Code:if (Position.MarketPosition == MarketPosition.Flat) { SetStopLoss(CalculationMode.Price, 0); }
Leave a comment:
-
Hello.
Dont run OK, something I'm doing wrong.
Maybe dont understand "Reset these variables when you're flat."
How can I do it.
Regards.
Leave a comment:
-
What's happening is your first condition continues to evaluate true. What you can do here is use bool variables so that this first movement is only evaluated once.
VariablesRegion:
private bool firstMove = true;
Code:if (Close[0] >= Position.AvgPrice + 8 * TickSize && firstMove) { SetStopLoss(CalculationMode.Price,Position.AvgPrice + 1 * TickSize); firstMove = false; } if (Close[0] >= Position.AvgPrice + 14 * TickSize) { SetStopLoss(CalculationMode.Price,Position.AvgPrice + 7 * TickSize); }
Last edited by NinjaTrader_RyanM1; 10-22-2010, 03:54 PM.
Leave a comment:
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by GussJ, 03-04-2020, 03:11 PM
|
16 responses
3,281 views
0 likes
|
Last Post
by Leafcutter
Today, 04:14 PM
|
||
Started by WHICKED, Today, 12:45 PM
|
2 responses
19 views
0 likes
|
Last Post
by WHICKED
Today, 03:36 PM
|
||
Started by Tim-c, Today, 02:10 PM
|
1 response
9 views
0 likes
|
Last Post Today, 02:52 PM | ||
Started by Taddypole, Today, 02:47 PM
|
0 responses
5 views
0 likes
|
Last Post
by Taddypole
Today, 02:47 PM
|
||
Started by chbruno, 04-24-2024, 04:10 PM
|
4 responses
53 views
0 likes
|
Last Post
by chbruno
Today, 02:38 PM
|
Leave a comment: