Powerlanguage Multicharts.NEt coding questions - MultiCharts | futures io social day trading
futures io futures trading


Powerlanguage Multicharts.NEt coding questions
Updated: Views / Replies:495 / 5
Created: by fjgaspar Attachments:0

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

Powerlanguage Multicharts.NEt coding questions

  #1 (permalink)
Elite Member
Sevilla + Spain
 
Futures Experience: Beginner
Platform: Multicharts
Favorite Futures: SP
 
Posts: 20 since May 2016
Thanks: 3 given, 2 received

Powerlanguage Multicharts.NEt coding questions

Hi,

I'm trying to code an strategy for automatic trading in multicharts.net platform, which uses powerlanguage coding language.

I have been able to code the conditions for strategy, but I need help with some questions that I am not able to figure out.

When certain conditions are met, my strategy needs to send 3 orders when current bar is closed: entry (long or short), stoploss, and profit target. I have code this and works ok.

The problem begins after that. When a new bar begins, the orders are sent. I need to achieve the following:

- If the entry order is executed, and when this bar ends and a new bar begins, neither the profit target nor the stoploss have been fullfilled, I need to move the stop loss to another level, and profit target has to keep. From them on, both orders have to keep unchanged until one of them executes.

- After the entry order is executed, if profit target or stop loss is executed at any time, in that same moment the remain order has to be cancelled in this moment: I can't wait until the bar closes.

- If the entry order is not executed during the bar in which has been sent, all 3 orders has to be cancelled upon bar close.

I need some help to code all those things.

Thank you.

Reply With Quote
 
  #2 (permalink)
 Vendor: tradingcode.net 
The Netherlands
 
Futures Experience: None
Platform: MultiCharts, TradingView
Favorite Futures: ...
 
Jura's Avatar
 
Posts: 774 since Apr 2010
Thanks: 2,347 given, 660 received


fjgaspar View Post
- If the entry order is executed, and when this bar ends and a new bar begins, neither the profit target nor the stoploss have been fullfilled, I need to move the stop loss to another level, and profit target has to keep. From them on, both orders have to keep unchanged until one of them executes.

How to code this depends on how you've already coded the profit target and stop-loss levels. Because it sounds to me what you're saying here is 'update the stop-loss level' with every bar. That can be done, of course, but how that depends on your strategy's logic.


fjgaspar View Post
- After the entry order is executed, if profit target or stop loss is executed at any time, in that same moment the remain order has to be cancelled in this moment: I can't wait until the bar closes.

Managed orders in MultiCharts .NET remain active until they are cancelled.

If you, for example, only submit the profit target and stop-loss order as long as there's an open position, then when the position is closed, the orders aren't submitted anymore (and thus cancelled).

If they have to be cancelled immediately in this moment, and not till the price bar closes, you need to use intra-bar order generation.



fjgaspar View Post
- If the entry order is not executed during the bar in which has been sent, all 3 orders has to be cancelled upon bar close.

You can do this by adding this logic to your entry conditions, for example by storing the bar number in a variable the first time the entry signal is generated. Then on each calculation you can compare how many bars have passed since that original entry signal, and if that's more than one bar (so the order hasn't been filled on the initial entry bar), then stop resubmitting the entry order.

Reply With Quote
The following user says Thank You to Jura for this post:
 
  #3 (permalink)
Elite Member
Sevilla + Spain
 
Futures Experience: Beginner
Platform: Multicharts
Favorite Futures: SP
 
Posts: 20 since May 2016
Thanks: 3 given, 2 received


Thank you for your answer.

Finally, I have solved all the problems.

I define 6 kinds of orders: One stop buy. One stop shellshort. These two are for entries (long or short). One limit sell (Profit for longs). One limit buytocover (profit for shorts), one stop sell (stop protection for longs) and one stop buytocover (stop protection for shorts.
After stablishing conditions for entry, stop loss and profit, I send an entry order to the market. Lets say a long position:

orderdefinedasstopbuy.send(price,price)
orderstoplong.Send(price)
orderprofitlong.Send(price)

When the conditions meet, at the start of the bar, ecery order is sent. The entry order becomes active, and the others don't reach the market because those kinds of orders can't exist without an open position.
If the bar finishes and the entry has not been executed, the order is automatically canceled (default behaviour of Multicharts).

If it has been executed, the two others orders reach the market, because the position is open and the orders were sent. If one of them is executed, the position is closed, and so, the other cannot exists anymore, so it is automatically canceled.

If tha bar ends without none of the orders executed, the code continue. I have added a block of code that ask for the position in market, so if the position is opened, the two 'protection' orders are sent again.

I have only another question that I haven't been able to solve. How can I know the execution price or an order? I mean that the script knows that price and store it into a variable. I know I can llok for execution price in the account page.

Reply With Quote
 
  #4 (permalink)
Market Wizard
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation, Multicharts.NET, NinjaTrader, MetaTrader
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,465 since Apr 2013
Thanks: 224 given, 835 received

fjgaspar,

depending on the automation mode you are using (Sync or Async) you can use the Strategy Performance related reserved words.
When operating in Sync mode the strategy positions on the chart will be updated when the broker reports them as filled and they have matching fill prices.

When operating in Async mode they are independent of the broker prices and can therefore be different. While the strategy performance related reserved words will still return the values as you see them on the chart, accessing the broker fill prices will likely require your code to subscribe to the TradeManager to monitor and track the position changes. You can find a few example in the official Multicharts forum on how to do that, but it's a bit slim and much more complex than using the performance related reserved words directly.

Regards,

ABCTG

Reply With Quote
 
  #5 (permalink)
Elite Member
Sevilla + Spain
 
Futures Experience: Beginner
Platform: Multicharts
Favorite Futures: SP
 
Posts: 20 since May 2016
Thanks: 3 given, 2 received

Thanks again.

I use Sync mode. I have tried with StrategyInfo.AvgEntryPrice but it returns 0. Maybe if I wait till next bar, it will give me the real value, but when I send an order type market, it gets executed in that moment and I have to know what is the execution price when is executed.

Reply With Quote
 
  #6 (permalink)
Market Wizard
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation, Multicharts.NET, NinjaTrader, MetaTrader
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,465 since Apr 2013
Thanks: 224 given, 835 received

Are you using intrabar order generation? If not, the values might only be updated at the end of the bar.

Regards,

ABCTG

Reply With Quote

Reply



futures io > > > > Powerlanguage Multicharts.NEt coding questions

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)
 

Introducing daytradr by Jigsaw, new stand-alone platform

Oct 19
 

RandBots: AutoTrading Bots to diversify your trading

Oct 24
 

TopstepTrader: Profiting Without Risking Your Own Money

Oct 26

Building Open Source Indicators for NT8 w/Fat Tails @ Lizard Indicators

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Where to start if you want to learn .NET powerlanguage uspilotzzz MultiCharts 3 April 20th, 2016 08:10 AM
The Booker Method (Powerlanguage .NET) Aufidius MultiCharts 0 March 2nd, 2016 01:48 PM
Convert AmiBroker Formula Language into MultiCharts PowerLanguage p2tr AmiBroker 0 March 24th, 2014 06:28 AM
Money management code in Multicharts PowerLanguage moses MultiCharts 1 March 18th, 2013 06:34 AM
Powerlanguage / Multicharts Strategy Stoploss code Wouter Elite EasyLanguage Automated Trading 10 September 17th, 2012 02:58 PM


All times are GMT -4. The time now is 02:22 PM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts
Page generated 2017-10-19 in 0.09 seconds with 19 queries on phoenix via your IP 23.20.86.177