NexusFi: Find Your Edge


Home Menu

 





Why strategy orders are not executed?


Discussion in MultiCharts

Updated
    1. trending_up 1,567 views
    2. thumb_up 0 thanks given
    3. group 1 followers
    1. forum 3 posts
    2. attach_file 1 attachments




 
Search this Thread

Why strategy orders are not executed?

  #1 (permalink)
r41866
Cypress Texas/USA
 
Posts: 10 since Mar 2021
Thanks Given: 0
Thanks Received: 1

I wrote 2 signals to open a long position according to the prior bar's height. Buy stop 1 tick above the prior bar's high and place a stop loss order 1 or 2 ticks below the low of the prior two bars. Take profit when the target reaches half of the risk. Now my signals show the entries and exits on the chart but however, it cannot execute orders at real time. The platform does nothing except drawing the orders on the chart and yet no real order is placed. I don't know what's gone wrong. Please help.

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Better Renko Gaps
The Elite Circle
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
How to apply profiles
Traders Hideout
What broker to use for trading palladium futures
Commodities
MC PL editor upgrade
MultiCharts
 
  #2 (permalink)
r41866
Cypress Texas/USA
 
Posts: 10 since Mar 2021
Thanks Given: 0
Thanks Received: 1

Below is the code for the entry signal. Max_Risk is the maximal risk tolerated for each trade in dollar amount and PerContract_Risk is the maximal risk tolerated per futures contract.

using System;
using System.Drawing;
using System.Linq;
using PowerLanguage.Function;
using ATCenterProxy.interop;


namespace PowerLanguage.Strategy
{
[IOGMode(IOGMode.Disabled)]
public class MackBuyStop_Open : SignalObject
{
// Create the inputs
[Input]
public double Max_Risk { get; set; }

[Input]
public double PerContract_Risk { get; set; }

public MackBuyStop_Open(object _ctx) : base(_ctx)
{
// Give the inputs a default value
Max_Risk = 880;
PerContract_Risk = 300;

}

private IOrderPriced enterLong;
private double TickValue, PointValue, BarRisk1, BarRisk2;


protected override void Create()
{
// Create the orders
enterLong = OrderCreator.Stop(new
SOrderParameters(Contracts.UserSpecified, EOrderAction.Buy));



}

protected override void StartCalc()
{
TickValue = Bars.Info.MinMove / Bars.Info.PriceScale ;
PointValue = Bars.Info.BigPointValue ;
Output.Clear();

}

protected override void CalcBar()
{

BarRisk1 = ( Bars.High[0] - Bars.Low.Lowest(2, 0) + 2 * TickValue ) * PointValue ;
BarRisk2 = BarRisk1 + TickValue*PointValue;
//Output.WriteLine(Bars.Time[0].ToString("d-M HH:mm:ss")+" StrategyInfo.MarketPosition = {0}\n", StrategyInfo.MarketPosition);
if ((CurrentPosition.Side == EMarketPositionSide.Flat) &&
( Bars.Close[0] - Bars.Open[0] > 0 ) &&
( (Bars.Close[0] - Bars.Low[0] ) / (Bars.High[0] > Bars.Low[0]? (Bars.High[0] - Bars.Low[0]):1000000) >= 0.6 ) &&
( BarRisk1 <= PerContract_Risk )) //((double)(Bars.High - Bars.Low) + 2 * TickValue)
{
// Output.WriteLine(Bars.Time[0].ToString("d-M HH:mm:ss")+" StrategyInfo.MarketPosition = {0}\n", StrategyInfo.MarketPosition);
// Output.WriteLine(Bars.Time[0].ToString("d-M HH:mm:ss")+" BarRisk1 = {0} BarRisk2 = {1}\n", BarRisk1, BarRisk2 );
if (BarRisk2 <= PerContract_Risk)
{
enterLong.Send(Bars.High[0] + TickValue, (int)(Max_Risk/BarRisk2));

}
else
{
enterLong.Send(Bars.High[0] + TickValue, (int)(Max_Risk/BarRisk1));
}

}


}
}
}

Reply With Quote
  #3 (permalink)
r41866
Cypress Texas/USA
 
Posts: 10 since Mar 2021
Thanks Given: 0
Thanks Received: 1


Below is the code for exit signal.

namespace PowerLanguage.Strategy
{
[IOGMode(IOGMode.Disabled)]
public class Mack_Single_Target_Exit : SignalObject
{

private double TickValue, PointValue, BarRisk1, BarRisk2;
private double Amount1;
public Mack_Single_Target_Exit(object ctx) :
base(ctx)
{
Amount = 880;
PerContractRisk = 300;
}


[Input]
public double Amount { get; set; }

[Input]
public double PerContractRisk { get; set; }

protected override void StartCalc()
{
TickValue = Bars.Info.MinMove / Bars.Info.PriceScale ;
PointValue = Bars.Info.BigPointValue ;
}

protected override void CalcBar(){
if (StrategyInfo.MarketPosition <0) Output.WriteLine(Bars.Time[0].ToString("d-M HH:mm:ss")+" Market Position = {0} \n", StrategyInfo.MarketPosition);
if (StrategyInfo.MarketPosition == 0) Amount1 = 0;
if (StrategyInfo.MarketPosition > 0 && Amount1 == 0 ){

BarRisk1 = ( Bars.High[1] - Bars.Low.Lowest(2, 1) + 2 * TickValue ) * PointValue ;
BarRisk2 = BarRisk1 + TickValue*PointValue;
if (BarRisk2 > PerContractRisk)
Amount1 = BarRisk1 ;
else
Amount1 = BarRisk2 ;
}

if (StrategyInfo.MarketPosition < 0 && Amount1 == 0 ){

BarRisk1 = ( Bars.High.Highest(2,1) - Bars.Low[1] + 2 * TickValue ) * PointValue ;
BarRisk2 = BarRisk1 + TickValue*PointValue;
if (BarRisk2 > PerContractRisk)
Amount1 = BarRisk1 ;
else
Amount1 = BarRisk2 ;
}
CurSpecOrdersMode = ESpecOrdersMode.PerContract;

if (StrategyInfo.MarketPosition != 0){
GenerateProfitTarget(Amount1 / 2);
GenerateStopLoss(Amount1);
Output.WriteLine(Bars.Time[0].ToString("d-M HH:mm:ss")+" Market Position = {0} Risk Amount = {1}\n", StrategyInfo.MarketPosition, Amount1);
}
}
}
}

Reply With Quote
  #4 (permalink)
r41866
Cypress Texas/USA
 
Posts: 10 since Mar 2021
Thanks Given: 0
Thanks Received: 1

Below is the chart marked with entries and exits. However, in real time, there is no order sent out.


Reply With Quote




Last Updated on March 19, 2021


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts